# CMake entry point
cmake_minimum_required (VERSION 2.6)
project (VectorTD)

find_package(OpenGL REQUIRED)

# Compile external dependencies 
add_subdirectory (external)

# On Visual 2005 and above, this module can set the debug working directory
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-1c73e35")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP

if(INCLUDE_DISTRIB)
	add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)



include_directories(
	external/AntTweakBar-1.15/include/
	external/glfw-2.7.6/include/
	external/glm-0.9.4.0/
	external/glew-1.9.0/include/
	external/jsoncpp-src-0.5.0/include
	src/
	.
)

set(ALL_LIBS
	${OPENGL_LIBRARY}
	GLFW_276
	GLEW_190
	json
)

add_definitions(
	-DTW_STATIC
	-DTW_NO_LIB_PRAGMA
	-DTW_NO_DIRECT3D
	-DGLEW_STATIC
	-D_CRT_SECURE_NO_WARNINGS
)

# VectorTD

FILE(GLOB states_files
    src/states/*.cpp
    src/states/*.h
)

FILE(GLOB renderer_files
    src/renderer/*.cpp
    src/renderer/*.h
)

FILE(GLOB game_files
    src/game/*.cpp
    src/game/*.h
)

FILE(GLOB common_files
    src/*.cpp
    src/*.h
)

FILE(GLOB bin_files
    bin/*.*
)

FILE(GLOB shaders_files
    bin/shaders/*.*
)

FILE(GLOB models_files
    bin/models/*.*
)

add_executable(VectorTD 
	${common_files}
	${states_files}
	${game_files}
	${renderer_files}
	# Ressources files
	${bin_files}
	${shaders_files}
	${models_files}
)


SOURCE_GROUP("Source Files" FILES ${common_files})
SOURCE_GROUP("Source Files\\states" FILES ${states_files})
SOURCE_GROUP("Source Files\\game" FILES ${game_files})
SOURCE_GROUP("Source Files\\renderer" FILES ${renderer_files})
SOURCE_GROUP("Ressources" FILES ${bin_files})
SOURCE_GROUP("Ressources\\shaders" FILES ${shaders_files})
SOURCE_GROUP("Ressources\\models" FILES ${models_files})

target_link_libraries(VectorTD
	${ALL_LIBS}
)
# Xcode and Visual working directories
set_target_properties(VectorTD PROPERTIES XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bin/")
create_target_launcher(VectorTD WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/")


SOURCE_GROUP(common REGULAR_EXPRESSION ".*/common/.*" )


#if (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
#add_custom_command(
#   TARGET tutorial01_first_window POST_BUILD
#   COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/tutorial01_first_window${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/tutorial01_first_window/"
#)

#endif (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )

